package com.frxuexi.park2210.park

import androidx.lifecycle.MutableLiveData
import com.frxuexi.lib_base.mvvm.BaseViewModel
import com.frxuexi.lib_base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import javax.inject.Inject

@HiltViewModel
class ParkViewModel @Inject constructor(val apiService: ApiService):BaseViewModel() {

    var parkSuc = MutableLiveData<String>()

    var colorSuc=MutableStateFlow<String>("")

    var addParkSuc = MutableLiveData<String>()

    fun getParks(){
        httpRequest({apiService.getParks()},parkSuc::postValue)
    }

    fun getColors(){
        httpRequest({apiService.getColors()},{colorSuc.value=it})
    }

    fun addPark(map: Map<String,Any>){
        httpRequest({apiService.addPark(mapToBody(map))},addParkSuc::postValue)
    }
}